package com.xczl.job.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.util.Assert;

import com.xczl.job.dao.JobDao;
import com.xczl.job.entity.Job;

@Service("jobJobService")
public class JobService {

	@Resource(name = "jobJobDao")
	private JobDao jobDao;
	

	public void add(Job job) {
		// 基本数据验证
		Assert.notNull(job, "没有兼职工作对象");
		Assert.notNull(job.getGender(), "性别不能为空");
		Assert.notNull(job.getPay(), "工资不能为空");
		Assert.notNull(job.getCert(), "证件不能为空");
		Assert.notNull(job.getWelfare(), "没有福利");
		Assert.notNull(job.getWorkData(), "工作日期不能为空");
		Assert.notNull(job.getWorkTime(), "工作时间不能为空");
		Assert.notNull(job.getWorkPlace(), "工作地点不能为空");
		Assert.notNull(job.getHeightDemand(), "不限身高");
		Assert.notNull(job.getTotalPeople(), "总人数不能为空");
		Assert.notNull(job.getDetails(), "没有岗位详情");
		Assert.notNull(job.getCollectionLocation(), "集合地点不能为空");
		Assert.notNull(job.getCollectionTime(), "集合时间不能为空");
		Assert.notNull(job.getDeadline(), "截至日期不能为空");

		// 初始化赋值
		job.setActualPeople(0);
		jobDao.insert(job);

	}

	/***
	 * 查询列表
	 * 
	 * @param offset
	 * @param rows
	 * @param search
	 * @return
	 */
	public List<Job> findListBySearch(Job search, int offset, int rows) {
		List<Job> list = jobDao.findListBySearch(search, offset, rows);
		return list;
	}
	public void del (int id) {
		Assert.notNull(id, "id不能为空");
		jobDao.del(id);
	}
	public void deadline(Job job){
		jobDao.deadline(job);
	}
	public void update(Job job){
	   jobDao.update(job);
		
	}
	public void updateActualPeople(Job job){
		jobDao.updateActualPeople(job); 
		
	}
}
